<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>反欺诈系统</b>！</p><br/></div   <p>&nbsp&nbsp;&nbsp;&nbsp;&nbsp;<a href="./index.php/Home/Miguan/index?phone=13979814646&id_card=420106199004292014&name=%E5%AD%99%E9%A2%9D%E9%98%BF%E8%90%A8%E5%BE%B7">蜜罐查询系统</a>&nbsp&nbsp;&nbsp;&nbsp;&nbsp; <a href="./index.php/Home/Suanhua/index"> 算话系统</a></p> ') ;
    }

    public function get()
    {
        echo 111;
    }

     public function daikuan(){
    	$tn=$_GET['tn'];
    	if(empty($_GET['tn'])){
			$this->error('请正确进入','index');die;
		}
		
    	if(IS_POST){
			$name=I('username');
    		$inputSmsCode=I('inputSmsCode');
    		$money=I('money');
    		$phone=I('phone');

    		$_SESSION['name']=$name;
    		$_SESSION['money']=$money;
    		$_SESSION['phone']=$phone;
    		if ($inputSmsCode!=$_SESSION['smscode']) {
    			$this->ajaxReturn(array('status'=>0,'msg'=>'验证码错误'));
    		} else{
    			$servername = C('servername');
				$username = C('username');
				$password =C('password');
				$dbname = C('dbname');
				   
				$conn=jscon($servername,$username,$password,$dbname);
				$tn=$_GET['tn'];
				$tn=intval($tn);
				$sql="SELECT Yg_Name FROM yuangong where id=$tn";
				$lr=jsOpenSql($conn,$sql);
				
				foreach ($lr as $v) {
					$lrczy=$v['Yg_Name'];
				}

				if (!empty($lrczy)) {
					$this->ajaxReturn(array('status'=>1,'n'=>$lrczy,'msg'=>'操作成功'));
				}else{
					$this->ajaxReturn(array('status'=>0,'n'=>$lrczy,'msg'=>'参数错误'));
				}
    			
    		 }
      	}
    	$this->assign('tn',$tn);

    	$this->display();
    }
    public function daikuantwo(){
    		$tn=$_GET['tn'];
    	if(empty($_GET['tn'])){
			$this->error('请正确进入','index');die;
		}
    	if(IS_POST){
    		$pzh=date('YmdHis01',time());
    			$servername = C('servername');
				$username = C('username');
				$password =C('password');
				$dbname = C('dbname');
			   
			$conn=jscon($servername,$username,$password,$dbname);
			
			$sql="SELECT Pzh FROM dKSqInfo ";
			$lr=jsOpenSql($conn,$sql);
			
			$tn=intval($tn);
			$sql1="SELECT Yg_Name FROM yuangong where id=$tn";
			$lrc=jsOpenSql($conn,$sql1);
			foreach ($lrc as $v) {
				$lr1['Yg_Name']=$v['Yg_Name'];
			}
			if (empty($lr1['Yg_Name'])) {

				$this->ajaxReturn(array('status'=>0,'msg'=>'参数错误'));die;

			}else{

				foreach ($lr as $v) {
				if ($v['Pzh']==$pzh) {
					$pzh=date('YmdHis02',time());
				}
			}
    		
				$lrzcy=$lr1['Yg_Name'];
	    		$dkqx=I('dkqx');
	    		$hnzk=I('hnzk');
	    		$ysr=I('ysr');
	    		$sfz=I('sfz');
	    		$ywcl=I('ywcl');
	    		$clqk=I('clqk');
	    		$ywfc=I('ywfc');
	    		$fcqk=I('fcqk');
	    		$name=$_SESSION['name'];
	    		$money=$_SESSION['money'];
	    		$phone=$_SESSION['phone'];
	    		$sqdate=date('Y-m-d H:i:s',time());
	    		$servername = C('servername');
				$username = C('username');
				$password =C('password');
				$dbname = C('dbname');
				   
				$conn=jscon($servername,$username,$password,$dbname);
				
				//$sql="SELECT * FROM dKSqInfo where ulxdh=CAST($phone AS nvarchar(100))";
				$b=jsExecSql($conn,"insert into dKSqInfo (UName,ulxr,Pzh,ULxdh,DkMoney,dkqx,uygz,usfz,ucl,uclmx,ufc,ufcmx,uhy,sqdate,lrczy) values('$name','$name','$pzh','$phone','$money','$dkqx','$ysr','$sfz','$ywcl','$clqk','$ywfc','$fcqk','$hnzk','$sqdate','$lrzcy')");
				

	    		if($b){
	    			$this->ajaxReturn(array('status'=>1,'msg'=>'操作成功'));
	    		}
			}
	
    	}

    	$this->assign('tn',$tn);
    	$this->display();
    }
    public function success(){
    	$tn=$_GET['tn'];
    	$this->assign('tn',$tn);
  //   	if(empty($_GET['tn'])){
		// 	$this->error('请正确进入','index');die;
		// }
    	$this->display();


    }
    public function getcode(){
    	$phone=I('phone');
		$smscode = rand(0,9).rand(0,9).rand(0,9).rand(0,9);
						
			$_SESSION['smscode']=$smscode;
						
						//$status = $Smsapi->send($phone,$contstr);
             $status=send_sms_aldy($phone,$smscode);
               if($status['msg'] == '发送成功'){
							$this->ajaxReturn(array('status'=>1,'msg'=>'发送成功'));
						}else{
							
							$this->ajaxReturn(array('status'=>0,'msg'=>'验证码发送频繁,'.$status['msg']));
						}

    }







    
}